<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<h:head>
		<title>Registration</title>
	</h:head>
	<h:body>
	<ui:include src="horizontal_menu.xhtml">
	<p>[TODO] password encription SHA-256
	   [TODO] citizen feature (we need to change also the entity)
	   [TODO] to show error message when the form is not correctly filled</p>
	</ui:include>
		<h:form>
				<p:panel header="Registration Form">
					<h:panelGrid columns="3" id="regGrid">
					
						<h:outputLabel for="username">Username:</h:outputLabel>
						<p:inputText id="username" binding="#{registrationBean.username}" value="#{registrationBean.user.username}" />
						<h:message  for="username" />
						
						<h:outputLabel for="email">Email:</h:outputLabel>
						<p:inputText id="email" binding="#{registrationBean.email}" value="#{registrationBean.user.email}" />
						<h:message  for="email" />
						
						<h:outputLabel for="password">Password:</h:outputLabel>
						<p:password id="password" binding="#{registrationBean.password}" value="#{registrationBean.user.password}"
					feedback="true" match="pwd2" label="Password"/>
					<h:message  for="password" />
					
						<h:outputLabel for="pwd2">Confirm Password:</h:outputLabel>
						<p:password id="pwd2" label="Confirm Password" value="#{registrationBean.user.password}"/>
						<h:message  for="pwd2" />
						
						<h:outputLabel for="ecode">ECode:</h:outputLabel>
						<p:inputText id="ecode" binding="#{registrationBean.ecode}" value="#{registrationBean.citizen.ecode}" />
						<h:message  for="ecode" />
						
						<h:outputLabel for="name">Name:</h:outputLabel>
						<p:inputText id="name" binding="#{registrationBean.name}" value="#{registrationBean.citizen.name}" />
						<h:message  for="name" />
						
						<h:outputLabel for="surname">Surame:</h:outputLabel>
						<p:inputText id="surname" binding="#{registrationBean.surname}" value="#{registrationBean.citizen.surname}" />
						<h:message  for="surname" />
						
						<h:outputLabel for="dob">Date of birdth</h:outputLabel>
						<p:calendar id="dob" binding="#{registrationBean.dob}" value="#{registrationBean.citizen.dob}" /> 
						<h:message  for="dob" />
					</h:panelGrid>
				<p:commandButton value="Register" update="regGrid"
				action="#{registrationBean.register()}" />

				</p:panel>
		</h:form>
		
	</h:body>
</html>